**************************************************************
** title:	The Motivation to Vote			 				**
** data:	MEDW						       				**
** authors:	Blais and Daoust								**
** date:	March 2020								    	**
**************************************************************

clear all
*Load MEDW dataset
use "Aggregated_18jan2016.dta", clear

**************************************************************
** 					Preparation							   	**
**************************************************************
set more off
numlabel, add

*Importance of the election (regional)=Q34A in ELECID 8:
replace Q20=Q34A if ELECID==8

*Municipal France municipal elections considered as regional:
recode LEVEL 4=2

*For Bavaria, we need to take the score of some variables in the 1st wave (questions were not re-asked in other waves):
gen guilty_baviere = Q31 if ELECID==13
bysort RESPID : egen D_guilt = mean(guilty_baviere) 
replace D_guilt=Q31 if Q31 !=.

gen interest_baviere = Q5 if ELECID==13
bysort RESPID : egen interest = mean(interest_baviere) 
replace interest=Q5 if Q5 !=.
replace interest=. if interest==99

gen education_baviere = SD2 if ELECID==13
bysort RESPID : egen education = mean(education_baviere) 
replace education=SD2 if SD2 !=.

gen duty_baviere = Q44B if ELECID==13
bysort RESPID : egen D = mean (duty_baviere) 
replace D=Q44B if Q44B !=.

*D_guilt was not ask in ELECID 20 & 21:
replace D_guilt=. if ELECID==20
replace D_guilt=. if ELECID==21

*****************************
****Dependent variable*******
*****************************

*Turnout
gen turnout=PQ5_2
replace turnout=0 if PQ5_2==9
replace turnout=0 if turnout==2
replace turnout=1 if PQ5_1==4
replace turnout=0 if PQ5_1==1
replace turnout=0 if PQ5_1==2
replace turnout=0 if PQ5_1==3
replace turnout=0 if PQ5_1==9

gen turnout_percent=turnout*100

******************************
****Independent variables*****
******************************

*Education, by country
gen edu=0

//Canada
replace edu=1 if inrange(education, 6, 11) & COUNTRY==5
//France
replace edu=1 if education==7 & COUNTRY==2
replace edu=1 if education==8 & COUNTRY==2
replace edu=1 if education==9 & COUNTRY==2
//Spain
replace edu=1 if education==4 & COUNTRY==3
replace edu=1 if education==5 & COUNTRY==3
replace edu=1 if education==6 & COUNTRY==3
//Switzerland
replace edu=1 if education==6 & COUNTRY==1
replace edu=1 if education==7 & COUNTRY==1
replace edu=1 if education==8 & COUNTRY==1
replace edu=1 if education==9 & COUNTRY==1
//Germanny
replace edu=1 if education==6 & COUNTRY==4
replace edu=1 if education==7 & COUNTRY==4

*Duty
replace D=. if D==9
replace D=0 if D==2
replace Q45A=. if Q45A==9
replace Q45B=. if Q45B==9
replace Q45C=. if Q45C==9
replace Q45D=. if Q45D==9

*Guilty of non voting
replace D_guilt=Q31 if ELECID != 12
replace D_guilt=. if D_guilt==9
replace D_guilt=0 if D_guilt==1
replace D_guilt=0.33 if D_guilt==2
replace D_guilt=0.67 if D_guilt==3
replace D_guilt=1 if D_guilt==4
*Note: these three elections do not have the guilt question:
drop if ELECID==19 | ELECID==20 | ELECID==21

*Sex
gen female=0
replace female=1 if GEND==2

*Age: Substract year of the election, minus year of birth to get age. 
replace YOB=2015-YOB if ELECID==25
replace YOB=2015-YOB if ELECID==26
replace YOB=2015-YOB if ELECID==27
replace YOB=2015-YOB if ELECID==24
replace YOB=2014-YOB if ELECID==22
replace YOB=2014-YOB if ELECID==23
replace YOB=2014-YOB if ELECID==16
replace YOB=2014-YOB if ELECID==17
replace YOB=2014-YOB if ELECID==20
replace YOB=2014-YOB if ELECID==21
replace YOB=2013-YOB if COUNTRY==4
replace YOB=2012-YOB if ELECID==8
replace YOB=2012-YOB if ELECID==15
replace YOB=2012-YOB if ELECID==5
replace YOB=2012-YOB if ELECID==6
replace YOB=2011-YOB if ELECID==7
replace YOB=2011-YOB if ELECID==9
replace YOB=2011-YOB if ELECID==14
replace YOB=2011-YOB if COUNTRY==1

rename YOB age

*Drop 111 years old and < 18 (not eligible to vote)
drop if age==111
drop if age < 18

*Create caterories of age instead of a continuum
gen age_group=.
replace age_group=1 if inrange(age, 18, 24)
replace age_group=2 if inrange(age, 25, 34)
replace age_group=3 if inrange(age, 35, 44)
replace age_group=4 if inrange(age, 45, 54)
replace age_group=5 if inrange(age, 55, 64)
replace age_group=6 if inrange(age, 65, 74)
replace age_group=7 if inrange(age, 75, 100)

*Dichotomize age (at 28, then at 35 years old)
gen age_dicho_28=0
replace age_dicho_28=1 if age > 27

gen age_dicho_34=0
replace age_dicho_34=1 if inrange(age, 35, 111)

gen age_45= 0 if inrange(age, 18,45)
replace age_45 = 1 if inrange(age, 46, 111)

*Easiness to vote
gen easy=. 
replace easy=0 if Q48==1
replace easy=0.33 if Q48==2
replace easy=0.67 if Q48==3
replace easy=1 if Q48==4

*Interest in politics generally speaking (Q5)
replace interest=interest/10

*Care
gen care=Q20
replace care=. if care==99
replace care=care/10

gen care_local=Q26
recode care_local 99=. 
replace care_local=care_local/10 

recode Q17_party* (99=.)

gen intensity_first=max(Q17_party1, Q17_party2, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13)
gen first_1=1 if Q17_party1==intensity_first
gen first_2=1 if Q17_party2==intensity_first
gen first_3=1 if Q17_party3==intensity_first
gen first_4=1 if Q17_party4==intensity_first
gen first_5=1 if Q17_party5==intensity_first
gen first_6=1 if Q17_party6==intensity_first
gen first_7=1 if Q17_party7==intensity_first
gen first_8=1 if Q17_party8==intensity_first
gen first_9=1 if Q17_party9==intensity_first
gen first_10=1 if Q17_party10==intensity_first
gen first_11=1 if Q17_party11==intensity_first
gen first_12=1 if Q17_party12==intensity_first
gen first_13=1 if Q17_party13==intensity_first

gen intensity_second=max(Q17_party2, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_1==1
replace intensity_second=max(Q17_party1, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_2==1
replace intensity_second=max(Q17_party1, Q17_party2, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_3==1
replace intensity_second=max(Q17_party1, Q17_party2, Q17_party3, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_4==1
replace intensity_second=max(Q17_party1, Q17_party2, Q17_party3, Q17_party4, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_5==1
replace intensity_second=max(Q17_party1, Q17_party2, Q17_party3, Q17_party4, Q17_party5, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_6==1
replace intensity_second=max(Q17_party1, Q17_party2, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_7==1
replace intensity_second=max(Q17_party1, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party2, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_8==1
replace intensity_second=max(Q17_party1, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party2, Q17_party10, Q17_party11, Q17_party12, Q17_party13) if first_9==1
replace intensity_second=max(Q17_party1, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party2, Q17_party11, Q17_party12, Q17_party13) if first_10==1
replace intensity_second=max(Q17_party1, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party2, Q17_party12, Q17_party13) if first_11==1
replace intensity_second=max(Q17_party1, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party2, Q17_party13) if first_12==1
replace intensity_second=max(Q17_party1, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party2) if first_13==1

gen intensity_range= max(Q17_party1, Q17_party2, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13) ///
						- min(Q17_party1, Q17_party2, Q17_party3, Q17_party4, Q17_party5, Q17_party6, Q17_party7, Q17_party8, Q17_party9, Q17_party10, Q17_party11, Q17_party12, Q17_party13)
replace intensity_range=intensity_range/10

gen importance=.
replace importance =Q34A if LEVEL==2 
replace importance =Q34B  if LEVEL==1 
replace importance =Q34D if LEVEL==3 
recode importance 99=. 
replace importance=importance/10

*Identify the face_saving treatment
gen face_saving=.
replace face_saving=1 if PQ5_1 !=. 
replace face_saving=0 if PQ5_2 !=. 

*Contextual factors (level of election and electoral sytem)
gen euro=0
replace euro=1 if LEVEL==3

gen regional=0
replace regional=1 if LEVEL==2

gen national=0
replace national=1 if LEVEL==1

gen PR=1
replace PR=0 if COUNTRY==5
replace PR=0 if ELECID==22
replace PR=0 if ELECID==23

*Weights according to real turnout
gen weight=.
replace weight= 0.530/0.8451 if ELECID==1 & turnout==1
replace weight=(1-0.530)/(1-0.8451) if ELECID==1 & turnout==0
replace weight= 0.4966/0.7881 if ELECID==2 & turnout==1
replace weight=(1-0.4966)/(1-0.7881) if ELECID==2 & turnout==0
replace weight= 0.435/0.8725 if ELECID==3 & turnout==1
replace weight=(1-0.435)/(1-0.8725) if ELECID==3 & turnout==0
replace weight= 0.352/0.8282 if ELECID==4 & turnout==1
replace weight=(1-0.352)/(1-0.8282) if ELECID==4 & turnout==0
replace weight=0.542/0.7929 if ELECID==5 & turnout==1
replace weight=(1-0.542)/(1-0.7929) if ELECID==5 & turnout==0
replace weight=0.560/0.8159 if ELECID==6 & turnout==1
replace weight=(1-0.560)/(1-0.8159) if ELECID==6 & turnout==0
replace weight=0.659/0.8876 if ELECID==7 & turnout==1
replace weight=(1-0.659)/(1-0.8876) if ELECID==7 & turnout==0
replace weight=0.700/0.9004 if ELECID==8 & turnout==1
replace weight=(1-0.700)/(1-0.9004) if ELECID==8 & turnout==0
replace weight=0.733/0.9315 if ELECID==9 & turnout==1
replace weight=(1-0.733)/(1-0.9315) if ELECID==9 & turnout==0
replace weight=0.734/0.9388 if ELECID==10 & turnout==1
replace weight=(1-0.734)/(1-0.9388) if ELECID==10 & turnout==0
replace weight=0.594/0.8353 if ELECID==11 & turnout==1
replace weight=(1-0.594)/(1-0.8353) if ELECID==11 & turnout==0
replace weight=0.700/0.9597 if ELECID==12 & turnout==1
replace weight=(1-0.700)/(1-0.9597) if ELECID==12 & turnout==0
replace weight=0.639/0.9336 if ELECID==13 & turnout==1
replace weight=(1-0.639)/(1-0.9336) if ELECID==13 & turnout==0
replace weight=0.492/0.8513 if ELECID==14 & turnout==1
replace weight=(1-0.492)/(1-0.8513) if ELECID==14 & turnout==0
replace weight=0.746/0.9134 if ELECID==15 & turnout==1
replace weight=(1-0.746)/(1-0.9134) if ELECID==15 & turnout==0
replace weight=0.433/0.7871 if ELECID==16 & turnout==1
replace weight=(1-0.433)/(1-0.7871) if ELECID==16 & turnout==0
replace weight=0.431/0.8024 if ELECID==17 & turnout==1
replace weight=(1-0.431)/(1-0.8024) if ELECID==17 & turnout==0
replace weight=0.491/0.7597 if ELECID==18 & turnout==1
replace weight=(1-0.491)/(1-0.7597) if ELECID==18 & turnout==0
replace weight=0.409/0.7794 if ELECID==19 & turnout==1
replace weight=0.549/0.8193 if ELECID==22 & turnout==1
replace weight=(1-0.549)/(1-0.8193) if ELECID==22 & turnout==0
replace weight=0.503/0.7823 if ELECID==23 & turnout==1
replace weight=(1-0.503)/(1-0.7823) if ELECID==23 & turnout==0
replace weight=0.657/0.9073 if ELECID==24 & turnout==1
replace weight=(1-0.657)/(1-0.9073) if ELECID==24 & turnout==0
replace weight= 0.6800/0.9152 if ELECID==25 & turnout==1
replace weight=(1-0.6800)/(1-0.9152) if ELECID==25 & turnout==0
replace weight= 0.7000/0.9197 if ELECID==26 & turnout==1
replace weight=(1-0.7000)/(1-0.9197) if ELECID==26 & turnout==0
replace weight= 0.6600/0.9030 if ELECID==27 & turnout==1
replace weight=(1-0.6600)/(1-0.9030) if ELECID==27 & turnout==0

*Creating a variable that will be use to cluster
egen cluster=group(ELECID)

************************************
****************Cleaning************
************************************

keep turnout turnout_percent age edu female interest D_guilt care easy ///
			 RESPID ELECID COUNTRY REGION LEVEL Q6 Q17_party* PQ5_* face_saving ///
			 D age_group age_dicho_28 face_saving age_dicho_34 care_local intensity_first ///
			 intensity_second intensity_range   importance euro regional national PR weight cluster
			 

drop if missing(age, edu, female, interest, turnout, D_guilt, care, easy)

*Rescale age 0 to 1
gen age_stand=(age-18)/69

*Label
label variable age Age
label variable age_stand Age
label variable edu "Post-sec education"
label variable female Woman
label variable interest "Political interest"
label variable D_guilt Duty
label variable care Care
label variable easy Easiness
label variable face_saving "Treatment"

************************************
*********Figures and Tables*********
************************************

**Figure 2.1:
twoway lpolyci turnout age [aweight=weight], ///
graphregion(color(white))  ylabel(0.3(.1)1)  xlabel(20(5)90) xtitle("Age (years)") ytitle(Turnout) legend(off) title(" ")

*Table 2.1:
logit turnout age_stand  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m1 
logit turnout age_stand edu ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m2
esttab m1 m2  using  "table2_1.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Note: Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Table 3.1.
est sto clear

reg interest age_stand edu ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m1
esttab m1   using  "table3_1.rtf", drop(*ELECID*) label  r2 b(2) se(2) replace /// 
					nonote addnotes("Entries are OLS regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Table 3.2.
est sto clear

logit turnout  age_stand  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m1 
logit turnout  age_stand edu  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m2
logit turnout  age_stand edu interest ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m3
margins, at(interest=(0(1)1))
margins, at(interest=(.3(.6).9))
esttab m1 m2 m3  using  "table3_1.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Figure 3.1
cibar interest [aweight=weight], over1(COUNTRY)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1) legend(off) ytitle("Mean of political interest") xtitle("Country") xlabel(1"Switzerland" 2"France" 3"Spain" 4"Germany" 5"Canada" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_3_1, replace
cibar interest [aweight=weight], over1(LEVEL)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1)  legend(off) ytitle(" ") xtitle("Level of election") xlabel(1"National" 2"Regional" 3"European" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_3_2, replace
graph combine Figure_3_1.gph Figure_3_2.gph, scale(1.5) ysize(3)  cols(2) 

*Figure 3.2
graph bar turnout_percent [aweight=weight], over(interest) ytitle("Voter turnout (%)")  b1title("Political interest")

*Figure 3.3
logit turnout age_stand edu interest ib11.ELECID  [pweight=weight], cluster(cluster) robust
margins, at(interest=(0(.1)1)) 
marginsplot, title(" ")  ylabe(.2(.1).8) 

*Figure 4.1
cibar D_guilt [aweight=weight], over1(COUNTRY)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1) legend(off) ytitle("Mean of duty") xtitle("Country") xlabel(1"Switzerland" 2"France" 3"Spain" 4"Germany" 5"Canada" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_4_1, replace
cibar D_guilt [aweight=weight], over1(LEVEL)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1)  legend(off) ytitle(" ") xtitle("Level of election") xlabel(1"National" 2"Regional" 3"European" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_4_2, replace
graph combine Figure_4_1.gph Figure_4_2.gph ,  scale(1.5) ysize(3)  cols(2) 

*Figure 4.2. 
logit turnout  age_stand edu interest D_guilt ib11.ELECID  [pweight=weight], cluster(cluster) robust
margins, at(D_guilt=(0 0.33 0.67 1)) 
marginsplot, title(" ") xlabel(0 "Not guilty at all" 0.33 "Not very guilty" 0.67 "Somewhat guilty" 1 "Very guilty",  ///
						labsize(vsmall) ) ylabe(.2(.1).8)

*Table 4.1.
est sto clear

reg D_guilt age_stand edu ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m1
reg D_guilt age_stand edu interest ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m2
margins, at(edu=(0 1))
margins, at(age=(30(30)60))
margins, at(interest=(0(0.1)1))

esttab m1 m2  using  "table4_1.rtf", drop(*ELECID*) label  r2 b(2) se(2) replace /// 
					nonote addnotes("Entries are OLS regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Table 4.2. 
est sto clear

logit turnout  age_stand  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m1
logit turnout  age_stand edu  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m2
logit turnout  age_stand edu interest ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m3
logit turnout  age_stand edu interest D_guilt ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m4

esttab m1 m2 m3 m4  using  "table4_2.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Figure 5.1
cibar care [aweight=weight], over1(COUNTRY)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1) legend(off) ytitle("Mean of care") xtitle("Country") xlabel(1"Switzerland" 2"France" 3"Spain" 4"Germany" 5"Canada" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_5_1, replace
cibar care [aweight=weight], over1(LEVEL)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1)  legend(off) ytitle(" ") xtitle("Level of election") xlabel(1"National" 2"Regional" 3"European" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_5_2, replace
graph combine Figure_5_1.gph Figure_5_2.gph, ysize(3) scale(1.5)   cols(2) 


*Table 5.1
est sto clear

reg care age_stand edu ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m1
reg care age_stand edu interest ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m2
reg care age_stand edu interest D_guilt ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m3

esttab m1 m2 m3   using  "table4_2.rtf", drop(*ELECID*) label  r2 b(2) se(2) replace /// 
					nonote addnotes("Entries are OLS regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Figure 5.2. 
logit turnout  age_stand edu interest D_guilt care ib11.ELECID  [pweight=weight], cluster(cluster) robust
margins, at(care=(0(.1)1)) 
marginsplot, title(" ") ylabe(.2(.1).8)
				 
*Table 5.2.
est sto clear

logit turnout  age_stand  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m1
logit turnout  age_stand edu  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m2
logit turnout  age_stand edu interest ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m3
logit turnout  age_stand edu interest D_guilt ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m4
logit turnout  age_stand edu interest D_guilt care ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m5

esttab m1 m2 m3 m4 m5 using  "table5_2.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

**Table 5.3. 
est sto clear

logit turnout age_stand edu interest D_guilt care care_local i.ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m1
logit turnout age_stand edu interest D_guilt intensity_range ib11.ELECID[pweight=weight], cluster(cluster) robust
est store m2

esttab m1 m2 using  "table5_3.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Table 6.1.
est sto clear

reg easy age_stand edu ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m1
reg easy age_stand edu interest ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m2
reg easy age_stand edu interest D_guilt ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m3
reg easy age_stand edu interest D_guilt care ib11.ELECID [pweight=weight], cluster(cluster) robust
est store m4

esttab m1 m2 m3 m4  using  "table6_1.rtf", drop(*ELECID*) label  r2 b(2) se(2) replace /// 
					nonote addnotes("Entries are OLS regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Table 6.2.
est sto clear

logit turnout  age_stand  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m1
logit turnout  age_stand edu  ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m2
logit turnout  age_stand edu interest ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m3
logit turnout  age_stand edu interest D_guilt ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m4
logit turnout  age_stand edu interest D_guilt care ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m5
logit turnout  age_stand edu interest D_guilt care easy ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m6

esttab m1 m2 m3 m4 m5 m6  using  "table6_2.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")


*Figure 6.1
cibar easy [aweight=weight], over1(COUNTRY)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1) legend(off) ytitle("Mean of ease") xtitle("Country") xlabel(1"Switzerland" 2"France" 3"Spain" 4"Germany" 5"Canada" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_6_1, replace
cibar easy [aweight=weight], over1(LEVEL)  level(95)  ciopts(lcolor(black)) ///
			graphopts(ylabel(0(.1)1)  legend(off) ytitle(" ") xtitle("Level of election") xlabel(1"National" 2"Regional" 3"European" )) ///
			 baropts(fcolor(white) lcolor(black)) 
graph save Figure_6_2, replace
graph combine Figure_6_1.gph Figure_6_2.gph,  ysize(3) scale(1.5)   cols(2) 


*Figure 6.2
logit turnout  age_stand edu interest D_guilt care easy ib11.ELECID  [pweight=weight], cluster(cluster) robust
margins, at(easy=(0 0.33 0.67 1)) 
marginsplot, title(" ") xlabel(0 "Very difficult" 0.33 "Somewhat difficult" 0.67 "Somewhat easy" 1 "Very easy",  ///
						labsize(vsmall) ) ylabel(.2(.1).8) xtitle("Ease")


*Table 7.1
est sto clear

logit turnout age_stand edu interest D_guilt care easy  c.age_stand#c.interest  c.age_stand#c.D_guilt c.age_stand#c.care c.age_stand#c.easy ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m1
logit turnout age_dicho_28 edu interest D_guilt care easy  c.age_dicho_28#c.interest  c.age_dicho_28#c.D_guilt c.age_dicho_28#c.care c.age_dicho_28#c.easy ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m2
logit turnout age_dicho_34 edu interest D_guilt care easy  c.age_dicho_34#c.interest  c.age_dicho_34#c.D_guilt c.age_dicho_34#c.care c.age_dicho_34#c.easy ib11.ELECID  [pweight=weight], cluster(cluster) robust
est store m3


esttab m1 m2 m3  using  "table7_1.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001") 					 
					 
*Other tables of Chapter 7: See do-files for the CSES and ANES datasets. 

*Table 8.1
est sto clear

melogit  turnout  [pweight=weight] || ELECID:
estat icc

mixed interest  [pweight=weight] || ELECID: , var
estat icc
est store a1
mixed D_guilt  [pweight=weight] || ELECID: , var
est store a2
estat icc
mixed care  [pweight=weight] || ELECID: , var
est store a3
estat icc
mixed easy  [pweight=weight] || ELECID: , var
est store a4
estat icc

esttab  a1 a2 a3 a4 using  "table8.1.rtf" , replace label b(2) se(2)


*Figure 8.1.
eststo clear

forvalues i = 1/24 {
	logit turnout  age_stand edu interest if cluster==`i'  [pweight=weight], robust 
	est sto a`i'
	logit turnout  age_stand edu interest D_guilt if cluster==`i' [pweight=weight], robust 
	est sto b`i'
	logit turnout  age_stand edu interest D_guilt care if cluster==`i' [pweight=weight], robust 
	est sto c`i'
	logit turnout  age_stand edu interest D_guilt care easy if cluster==`i' [pweight=weight], robust 	
	est sto d`i'
	}

esttab  a* using "~/Desktop/motivtaiton.rtf", ///
		label replace nogap  compress r2 b(3) se(3) nonumbers mlabels(,titles) 
esttab  b* using "~/Desktop/motivtaiton.rtf", ///
		label replace nogap  compress r2 b(3) se(3) nonumbers mlabels(,titles) 
esttab  c* using "~/Desktop/motivtaiton.rtf", ///
		label replace nogap  compress r2 b(3) se(3) nonumbers mlabels(,titles) 
esttab  d* using "~/Desktop/motivtaiton.rtf", ///
		label replace nogap  compress r2 b(3) se(3) nonumbers mlabels(,titles) 


coefplot a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24, ///
		keep(interest) bycoefs vertical ylabel(0(1)6) legend(off) yline(0, lcolor(black))  title("Political interest") ///
		lpatt(dash)lcol(black)msym(c)mcol(black)ciopts(lpatt(dash)lcol(black)) ytitle(Coefficient) xlabel(1 " ", notick)	
graph save "Figre8.1_1", replace

coefplot b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24, ///
			keep(D_guilt) bycoefs vertical ylabel(0(1)6) legend(off) yline(0, lcolor(black))  title("Duty") ///
			lpatt(dash)lcol(black)msym(c)mcol(black)ciopts(lpatt(dash)lcol(black)) xlabel(1 " ", notick)	
graph save "Figre8.1_2", replace

coefplot c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24, ///
			keep(care) bycoefs vertical ylabel(-2(1)6) legend(off)  ytitle(Coefficient) yline(0, lcolor(black)) title("Care") ///
			lpatt(dash)lcol(black)msym(c)mcol(black)ciopts(lpatt(dash)lcol(black)) xlabel(1 " ", notick)	
graph save "Figre8.1_3", replace

coefplot d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d9 d20 d21 d22 d23 d24, ///
			keep(easy) bycoefs vertical ylabel(-2(1)6) legend(off)   yline(0, lcolor(black)) title("Ease") ///
			lpatt(dash)lcol(black)msym(c)mcol(black)ciopts(lpatt(dash)lcol(black)) xlabel(1 " ", notick)	
graph save "Figre8.1_4", replace

graph combine "Figre8.1_1" "Figre8.1_2" "Figre8.1_3" "Figre8.1_4"					 

		
*Figure 8.2
logit  turnout age edu interest i.PR  c.interest#i.PR ///
			[pweight=weight], robust 	
			est store a1
margins, dydx(interest) at(PR=1 PR=0)
marginsplot,  title("Political interest") ytitle("Average marginal effect", size(small)) xtitle(" ") ylabel(.1(.1).6)  xlabel(-0.5(0.5)1.5 ///
				-0.5 " " 0.5 " " 1.5 " " 0 "Non-PR" 1 "PR")    recast(scatter)
graph save t1, replace		
logit  turnout age edu interest D_guilt  i.PR   c.D_guilt#i.PR  ///
			[pweight=weight], robust 	
			est store a2		
margins, dydx(D_guilt) at(PR=1 PR=0)
marginsplot,  title("Duty")  ytitle(" ")  xtitle(" ") ylabel(.1(.1).6)  xlabel(-0.5(0.5)1.5 ///
				-0.5 " " 0.5 " " 1.5 " " 0 "Non-PR" 1 "PR")    recast(scatter)
graph save t2, replace	
logit  turnout age edu interest D_guilt care i.PR  c.care#i.PR  ///
			[pweight=weight], robust 	
			est store a3
margins, dydx(care) at(PR=1 PR=0)	
marginsplot,  title("Care")  ytitle("Average marginal effect", size(small))  xtitle(" ") ylabel(.1(.1).6)  xlabel(-0.5(0.5)1.5 ///
				-0.5 " " 0.5 " " 1.5 " " 0 "Non-PR" 1 "PR")   recast(scatter)
graph save t3, replace	
logit  turnout age edu interest D_guilt care easy i.PR   c.easy#i.PR ///
			[pweight=weight], robust 	
			est store a4
margins, dydx(easy) at(PR=1 PR=0)	
marginsplot,  title("Ease")  ytitle(" ")  xtitle(" ") ylabel(.1(.1).6)  xlabel(-0.5(0.5)1.5 ///
				-0.5 " " 0.5 " " 1.5 " " 0 "Non-PR" 1 "PR")  recast(scatter)
graph save t4, replace	

graph combine t1.gph t2.gph t3.gph t4.gph 

*Figure 8.3
logit  turnout age edu interest   ib1.LEVEL  ///
			c.interest#ib1.LEVEL ///
			c.interest#ib1.LEVEL ///
			[pweight=weight], robust
margins, dydx(interest) at(LEVEL=1 LEVEL=2 LEVEL=3)	
marginsplot, title("Political interest") ytitle("Average marginal effect", size(small)) xtitle(" ") ylabel(.1(.1).6) xlabel(0(1)4 ///
				0 " " 1 "National" 2 "Regional" 3 "European" 4 " ")   recast(scatter)
graph save cri21, replace			
logit  turnout age edu interest D_guilt   ib1.LEVEL  ///
			 c.D_guilt#ib1.LEVEL ///
			c.D_guilt#ib1.LEVEL  ///
			[pweight=weight], robust
est store b2
margins, dydx(D_guilt) at(LEVEL=1 LEVEL=2 LEVEL=3)	
marginsplot, title("Duty") ytitle(" ") xtitle(" ") ylabel(.1(.1).6) xlabel(0(1)4 ///
				0 " " 1 "National" 2 "Regional" 3 "European" 4 " ")   recast(scatter)
graph save cri22, replace					
logit  turnout age edu interest D_guilt care   ib1.LEVEL ///
			c.care#ib1.LEVEL ///
			 c.care#ib1.LEVEL ///
			[pweight=weight], robust
est store b3		
margins, dydx(care) at(LEVEL=1 LEVEL=2 LEVEL=3)	
marginsplot, title("Care") xtitle(" ") ytitle("Average marginal effect", size(small)) ylabel(.1(.1).6) xlabel(0(1)4 ///
				0 " " 1 "National" 2 "Regional" 3 "European" 4 " ")   recast(scatter)
graph save cri23, replace		
logit  turnout age edu interest D_guilt care easy  ib1.LEVEL ///
			 c.easy#ib1.LEVEL ///
			c.easy#ib1.LEVEL ///
			[pweight=weight], robust
est store b4	
margins, dydx(easy) at(LEVEL=1 LEVEL=2 LEVEL=3)	
marginsplot, title("Ease") xtitle(" ") ytitle(" ")  ylabel(.1(.1).6) xlabel(0(1)4 ///
				0 " " 1 "National" 2 "Regional" 3 "European" 4 " ")   recast(scatter)
graph save cri24, replace		
	
graph combine cri21.gph cri22.gph cri23.gph cri24.gph

*Compare two individuals low/high on all 4 factors
logit turnout  age_stand edu interest D_guilt care easy ib11.ELECID  [pweight=weight] if PR==0, cluster(cluster) robust
margins, at(interest=.3 D_guilt=0 care=.5 easy=.5)
margins, at(interest=.9 D_guilt=.8 care=1 easy=1)
logit turnout  age_stand edu interest D_guilt care easy ib11.ELECID  [pweight=weight] if PR==1, cluster(cluster) robust
margins, at(interest=.3 D_guilt=0 care=.5 easy=.5)
margins, at(interest=.9 D_guilt=.8 care=1 easy=1)

************************************
*************APPENDIX***************
************************************

*Table A2
gen treatment_sample=1
replace treatment_sample=0 if ELECID ==10 | ELECID ==12 | ELECID ==13

eststo clear

logit turnout age_stand edu interest D_guilt care easy i.face_saving  i.face_saving#c.interest ib11.ELECID [pweight=weight] if treatment_sample==1, cluster(cluster) robust
est store a1
logit turnout age_stand edu interest D_guilt care easy i.face_saving  i.face_saving#c.D_guilt ib11.ELECID [pweight=weight] if treatment_sample==1, cluster(cluster) robust
est store a2
logit turnout age_stand edu interest D_guilt care easy i.face_saving  i.face_saving#c.care ib11.ELECID [pweight=weight] if treatment_sample==1, cluster(cluster) robust
est store a3
logit turnout age_stand edu interest D_guilt care easy i.face_saving   i.face_saving#c.easy ib11.ELECID [pweight=weight] if treatment_sample==1, cluster(cluster) robust
est store a4

esttab a1 a2 a3 a4  using  "tablea2.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")

*Table A3
eststo clear

logit turnout age_stand  ib11.ELECID, cluster(cluster) robust
est store a1
logit turnout age_stand edu  ib11.ELECID, cluster(cluster) robust
est store a2
logit turnout age_stand edu interest  ib11.ELECID, cluster(cluster) robust
est store a3
logit turnout age_stand edu interest D_guilt  ib11.ELECID, cluster(cluster) robust
est store a4
logit turnout age_stand edu interest D_guilt care  ib11.ELECID, cluster(cluster) robust
est store a5
logit turnout age_stand edu interest D_guilt care easy  ib11.ELECID, cluster(cluster) robust
est store a6

esttab a1 a2 a3 a4 a5 a6  using  "tablea3.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001") 

*Table A4
eststo clear

logit turnout age_stand edu interest D_guilt care easy c.interest#c.D_guilt  ib11.ELECID   [pweight=weight], cluster(cluster) robust
est store a1
logit turnout age_stand edu interest D_guilt care easy c.D_guilt#c.care  ib11.ELECID   [pweight=weight], cluster(cluster) robust
est store a2
logit turnout age_stand edu interest D_guilt care easy c.care#c.easy  ib11.ELECID   [pweight=weight], cluster(cluster) robust
est store a3


esttab a1 a2 a3  using  "tablea4.rtf", drop(*ELECID*) label  pr2 b(2) se(2) replace /// 
					nonote addnotes("Entries are logistic regression coefficients." "Robust standard errors, clustered by election, are in parentheses." ///
					 "Note: Election fixed-effects are included." "* p < 0.05, ** p < 0.01, *** p < 0.001")
